package com.loto.insurance.mis.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.loto.insurance.mis.web.authority.INSAuthority;
import com.loto.insurance.mis.web.enumeration.MenuEnum;
import com.loto.insurance.mis.web.service.OemService;

@Controller
public class OemController {
  @Autowired
  OemService oemService;

  @INSAuthority(authorityMenu = MenuEnum.OEM_LIST)
  @RequestMapping(value = "/oem/list", method = RequestMethod.GET)
  public String oemlist(Model model) {
	model.addAttribute("subId", MenuEnum.OEM_LIST.getIndex());
	return "oem/oem_list";
  }

  @INSAuthority(authorityMenu = MenuEnum.OEM_LIST)
  @RequestMapping(value = "/oem/detail", method = RequestMethod.GET)
  public String oemdetail(
	  @RequestParam(value = "id", required = false) String oemId, Model model) {
	if (oemId != null && !oemId.isEmpty()) {
	  model.addAttribute("oem", oemService.findOemById(oemId));
	}
	return "oem/oem_detail";
  }
}
